class Animal{
    public String name;
    public int age;
    public void eat(){
        System.out.println(name+" 正在吃饭！");
    }
    public Animal(String name,int age){
        this.name = name;
        this.age = age;
    }
    static {
        System.out.println("Animal的静态代码块！");
    }
    {
        System.out.println("Animal的实例代码块！");
    }
}
class Dog extends Animal{
//    public String name;
//    public int age;
    public float weight;
    public Dog(String name,int age,float weight){
        super(name,age);
        this.weight = weight;
    }

//    public void eat(){
//        System.out.println(name+" 正在吃饭！");
//    }
    public void bark(){
        System.out.println(name+" 正在汪汪汪！");
    }


    @Override
    public String toString() {
        return "Dog{" +
                "weight=" + weight +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
    static {
        System.out.println("Dog的静态代码块！");
    }
    {
        System.out.println("Dog的实例代码块！");
    }
}
class Cat extends Animal{
//    public String name;
//    public int age;
//    public void eat(){
//        System.out.println(name+" 正在吃饭！");
//    }
    public Cat(String name,int age){
        super(name, age);
    }
    public void miaomiao(){
        System.out.println(name+" 正在miaomiao");
    }
}

public class Test {

    public static void main(String[] args) {
//        继承：将共性进行抽取,实现代码的复用。
        Dog dog = new Dog();
        dog.name = "狗子";
        dog.age = 10;
        dog.weight = 48;
        dog.bark();
        dog.eat();
        System.out.println(dog);
    }
}
